package interfacesSIAB;

import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JTabbedPane;

import java.awt.Color;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JSplitPane;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
import java.awt.Point;
import java.awt.ComponentOrientation;
import javax.swing.WindowConstants;

import administrador.gestion_de_productos;

public class VentanaAdministrador extends JFrame {

	
	
	
	private JPanel jPanel2 = null;
	private JPanel jPanel1 = null;
	private JPanel jContentPane = null;
	private static final long serialVersionUID = 1L;
	private JTabbedPane jTabbedPane = null;
	private JPanel jPanel = null;
	private JPanel jPanel4 = null;
	private JPanel jPanel5 = null;
	private JCheckBox jCheckBox = null;
	private JCheckBox jCheckBox1 = null;
	private JButton aceptarEmp = null;
	ButtonGroup  pro = new javax.swing.ButtonGroup();
	ButtonGroup bt = new javax.swing.ButtonGroup();  //  @jve:decl-index=0:
	ButtonGroup emple = new javax.swing.ButtonGroup();  //  @jve:decl-index=0:
	ButtonGroup produ = new javax.swing.ButtonGroup();//  @jve:decl-index=0:
	private JCheckBox jCheckBox3 = null;
	private JCheckBox registrarCliente = null;
	private JCheckBox eliminarCliente = null;
	private JCheckBox listarCliente = null;
	private JButton aceptar1 = null;
	private JPanel Insumos = null;
	private JPanel jPanel3 = null;
	private JPanel jPanel6 = null;
	private JCheckBox RegProducto = null;
	private JCheckBox EliProducto = null;
	private JCheckBox LisProductos = null;
	private JButton Aceptar3 = null;
	private JCheckBox ingresarProveedor = null;
	private JCheckBox retirarProveedor = null;
	private JCheckBox buscarProveedor = null;
	private JButton AceptarProveedor = null;
	private JButton cancelar = null;
	private JButton cancelar1 = null;
	private JButton cancelar2 = null;
	private JButton cancelar21 = null;
	private JPanel jPanel11 = null;
	private JPanel jPanel12 = null;
	private JLabel jLabel = null;
	private JLabel jLabel1 = null;
	private JComboBox jComboBox = null;
	private JTextField jTextField = null;
	private JButton guardar = null;
	private JButton jButton3 = null;
	private JTextField cantidad = null;

	/**
	 * This is the default constructor
	 */
	public VentanaAdministrador() {
		super();
		initialize();
	}
	public ButtonGroup getProdu() {
		return produ;
	}


	public void setProdu(ButtonGroup produ) {
		this.produ = produ;
	}


	public ButtonGroup getBt() {
		return bt;
	}
	public ButtonGroup getpro() {
		return pro;
	}
	
	public ButtonGroup getEmple() {
		return bt;
	}
	public void setBt(ButtonGroup bt) {
		this.bt = bt;
	}


	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setContentPane(getJContentPane());
		this.setTitle("Administrador");
		this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
		this.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
		this.setLocation(new Point(300, 250));
		this.setSize(new Dimension(553, 505));
		this.setResizable(false);
	}

	
	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJTabbedPane(), null);
		}
		return jContentPane;
	}
	

	/**
	 * This method initializes jTabbedPane	
	 * 	
	 * @return javax.swing.JTabbedPane	
	 */
	private JTabbedPane getJTabbedPane() {
		if (jTabbedPane == null) {
			jTabbedPane = new JTabbedPane();
			
			jTabbedPane.setBounds(new Rectangle(6, 16, 509, 443));
			jTabbedPane.addTab("Empleados", new ImageIcon(getClass().getResource("/imagenes/empleados.jpg")), getJPanel(), null);
			jTabbedPane.addTab("Clientes", new ImageIcon(getClass().getResource("/imagenes/cliente.jpg")), getJPanel4(), null);
			jTabbedPane.addTab("Productos", new ImageIcon(getClass().getResource("/imagenes/productos.jpg")), getJPanel5(), null);
			jTabbedPane.addTab("Proveedores", new ImageIcon(getClass().getResource("/imagenes/proveedores.jpg")), getInsumos(), null);
			jTabbedPane.addTab("Insumos", null, getJPanel11(), null);
	
			
		}
		return jTabbedPane;
	}
	
	private JPanel getJPanel3() {
		if (jPanel3 == null) {
			jPanel3 = new JPanel();
			jPanel3.setLayout(null);
			jPanel3.setBounds(new Rectangle(32, 19, 283, 248));
			jPanel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.orange), "Gestion Proveedores ", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
			jPanel3.add(getIngresarProveedor(), null);
			jPanel3.add(getRetirarProveedor(), null);
			jPanel3.add(getBuscarProveedor(), null);
			
			
			getpro().add(ingresarProveedor);
			getpro().add(retirarProveedor);
			getpro().add(buscarProveedor);
			
			
			
			
			
			
		}
		return jPanel3;
	}

	private JCheckBox getBuscarProveedor() {
		if (buscarProveedor == null) {
			buscarProveedor = new JCheckBox();
			buscarProveedor.setBounds(new Rectangle(38, 135, 168, 21));
			buscarProveedor.setText("       Buscar Proveedor");
		}
		return buscarProveedor;
	}

	private JCheckBox getIngresarProveedor() {
		if (ingresarProveedor == null) {
			ingresarProveedor = new JCheckBox();
			ingresarProveedor.setBounds(new Rectangle(37, 66, 165, 21));
			ingresarProveedor.setText("        Ingresar Proveedor");
		}
		return ingresarProveedor;
	}
	private JCheckBox getRetirarProveedor() {
		if (retirarProveedor == null) {
			retirarProveedor = new JCheckBox();
			retirarProveedor.setBounds(new Rectangle(38, 97, 183, 21));
			retirarProveedor.setText("        Retirar Proveedor");
		}
		return retirarProveedor;
	}

	
	private JPanel getJPanel() {
		if (jPanel == null) {
			jPanel = new JPanel();
			jPanel.setLayout(null);
			jPanel.add(getJPanel1(), null);
			jPanel.add(getAceptarEmp(), null);
			jPanel.add(getCancelar2(), null);
		}
		return jPanel;
	}

	private JPanel getJPanel1() {
		if (jPanel1 == null) {
			jPanel1 = new JPanel();
			jPanel1.setLayout(null);
			jPanel1.setBounds(new Rectangle(31, 14, 302, 277));
			jPanel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.orange), "Gestion de Empleados", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), Color.black));
			jPanel1.add(getJCheckBox(), null);
			jPanel1.add(getJCheckBox1(), null);
			jPanel1.add(getJCheckBox3(), null);
			getBt().add(jCheckBox);
			getBt().add(jCheckBox1);
			getBt().add(jCheckBox3);
			
		
			
		}
		return jPanel1;
	}
	
	private JCheckBox getJCheckBox3() {
		if (jCheckBox3 == null) {
			jCheckBox3 = new JCheckBox();
			jCheckBox3.setBounds(new Rectangle(34, 133, 153, 21));
			jCheckBox3.setText("      Buscar Empleado");
		}
		return jCheckBox3;
	}



	
	
	private JCheckBox getJCheckBox1() {
		if (jCheckBox1 == null) {
			jCheckBox1 = new JCheckBox();
			jCheckBox1.setBounds(new Rectangle(34, 103, 153, 21));
			jCheckBox1.setText("      Retirar Empleado");
		}
		return jCheckBox1;
	}
	private JCheckBox getJCheckBox() {
		if (jCheckBox == null) {
			jCheckBox = new JCheckBox();
			jCheckBox.setBounds(new Rectangle(34, 62, 153, 21));
			jCheckBox.setMnemonic(KeyEvent.VK_UNDEFINED);
			jCheckBox.setRolloverEnabled(false);
			jCheckBox.setText("      Agregar Empleado");
		}
		return jCheckBox;
	}

	private JButton getCancelar2() {
		if (cancelar2 == null) {
			cancelar2 = new JButton();
			cancelar2.setBounds(new Rectangle(351, 83, 85, 26));
			cancelar2.setText("Salir");
			
					
			
             cancelar2.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					
					dispose();
				}
			});
			
		
					
			
		}
		return cancelar2;
	}


	
	private JButton getAceptarEmp() {
		if (aceptarEmp == null) {
			aceptarEmp = new JButton();
			aceptarEmp.setText("Aceptar");
			aceptarEmp.setBounds(new Rectangle(350, 32, 91, 26));
			
			aceptarEmp.addActionListener(new ActionListener(){
				
				public void actionPerformed( ActionEvent arg0 ){
					
					
					if(jCheckBox.isSelected()){
						
						IngresarEmpleado ven =new IngresarEmpleado();
						ven.setLocationRelativeTo(null);
						ven.setVisible(true);
						
						
					}
					
                   if(jCheckBox1.isSelected()){
						
						RetirarEmpleado re =new RetirarEmpleado();
						re.setLocationRelativeTo(null);
						re.setVisible(true);
						
						
					}
					
                   
					
					
                   if(jCheckBox3.isSelected()){
						
						BuscarEmpleado act =new BuscarEmpleado();
						act.setLocationRelativeTo(null);
						act.setVisible(true);
						
						
					}
					
				}
				
				
				
			});
			
			
		}
		return aceptarEmp;
	}


	
	
	
	private JPanel getInsumos() {
		if (Insumos == null) {
			Insumos = new JPanel();
			Insumos.setLayout(null);
			Insumos.add(getJPanel3(), null);
			Insumos.add(getAceptarProveedor(), null);
			Insumos.add(getCancelar1(), null);
		}
		return Insumos;
	}
	private JButton getAceptarProveedor() {
		if (AceptarProveedor == null) {
			AceptarProveedor = new JButton();
			AceptarProveedor.setBounds(new Rectangle(341, 44, 99, 24));
			AceptarProveedor.setText("Aceptar");
			
AceptarProveedor.addActionListener(new ActionListener(){
				
				public void actionPerformed( ActionEvent arg0 ){
					
					
					if(ingresarProveedor.isSelected()){
						
						IngresarProveedor ven =new IngresarProveedor();
						ven.setLocationRelativeTo(null);
						ven.setVisible(true);
						
						
					}
					
                   if(retirarProveedor.isSelected()){
						
						RetirarProveedor re =new RetirarProveedor();
						re.setLocationRelativeTo(null);
						re.setVisible(true);
						
						
					}
					
                   if(buscarProveedor.isSelected()){
						
						BuscarProveedor act =new BuscarProveedor();
						act.setLocationRelativeTo(null);
						act.setVisible(true);
						
						
					}
					
					
                   
					
					
					
					
					
					
				}
				
				
				
			});
			
			
			
		}
		
		return AceptarProveedor;
	

}  //  @jve:decl-index=0:visual-constraint="96,110"
	private JButton getCancelar1() {
		if (cancelar1 == null) {
			cancelar1 = new JButton();
			cancelar1.setBounds(new Rectangle(344, 96, 85, 26));
			cancelar1.setText("Salir");
cancelar1.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					
					dispose();
				}
			});
			
		
					
			
		}
		return cancelar1;
	}


	
	private JPanel getJPanel11() {
		if (jPanel11 == null) {
			jPanel11 = new JPanel();
			jPanel11.setLayout(null);
			jPanel11.add(getJPanel12(), null);
		}
		return jPanel11;
	}
	
	private JPanel getJPanel12() {
		if (jPanel12 == null) {
			jLabel1 = new JLabel();
			jLabel1.setBounds(new Rectangle(28, 114, 119, 16));
			jLabel1.setText("Ingrese Cantidad");
			jLabel = new JLabel();
			jLabel.setBounds(new Rectangle(26, 62, 138, 16));
			jLabel.setText("Seleccione  Insumo");
			jPanel12 = new JPanel();
			jPanel12.setLayout(null);
			jPanel12.setBounds(new Rectangle(21, 26, 422, 252));
			jPanel12.setBorder(BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.orange), "Gestion Insumos ", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
			jPanel12.add(jLabel, null);
			jPanel12.add(jLabel1, null);
			jPanel12.add(getJComboBox(), null);
			
			jPanel12.add(getGuardar(), null);
			jPanel12.add(getJButton3(), null);
			jPanel12.add(getCantidad(), null);
		}
		return jPanel12;
	}
	
	
	
	private JComboBox getJComboBox() {
		if (jComboBox == null) {
			jComboBox = new JComboBox();
			jComboBox.setBounds(new Rectangle(216, 58, 153, 25));
			
			jComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Pollo Asado", "Pollo Apanado", "Gaseosa  1.5 Litro","Gaseosa 2.5 Litros","Gaseosa 350 ml","Gaseosa 250 ml" ,"Gaseosa 10 onzas","Agua en Botella","Arepas","yuca","Cerveza","Gopack","Papa","Ensalada","Francesa","Arroz","Frijol","Consome completo","Consome","" }));
			
			
		
			
		}
		return jComboBox;
	}

	private JPanel getJPanel5() {
		if (jPanel5 == null) {
			jPanel5 = new JPanel();
			jPanel5.setLayout(null);
			jPanel5.add(getJPanel6(), null);
			jPanel5.add(getAceptar3(), null);
			jPanel5.add(getCancelar(), null);
		}
		return jPanel5;
	}
	private JButton getCancelar() {
		if (cancelar == null) {
			cancelar = new JButton();
			cancelar.setBounds(new Rectangle(341, 78, 91, 26));
			cancelar.setText("Salir");
			
cancelar.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					
					dispose();
				}
			});
			
			
			
		}
		return cancelar;
	}

	
	
	
	private JButton getAceptar3() {
		if (Aceptar3 == null) {
			Aceptar3 = new JButton();
			Aceptar3.setText("Aceptar");
			Aceptar3.setBounds(new Rectangle(341, 32, 90, 24));
			
			
			
Aceptar3.addActionListener(new ActionListener(){
				
				public void actionPerformed( ActionEvent arg0 ){
					
					
					if(RegProducto.isSelected()){
						
						IngresarProducto ven =new IngresarProducto();
						ven.setLocationRelativeTo(null);
						ven.setVisible(true);
						
						
					}
					
                   if(EliProducto.isSelected()){
						
						RetirarProducto re =new RetirarProducto();
						re.setLocationRelativeTo(null);
						re.setVisible(true);
						
						
					}
					
                  
					
					
                   if(LisProductos.isSelected()){
						
						BuscarProducto act =new BuscarProducto();
						act.setLocationRelativeTo(null);
						act.setVisible(true);
						
						
					}
					
					
					
					
					
					
					
				}
				
				
				
			});
			
	
			
			
			
			
			
			
			
			
			
		}
		return Aceptar3;
	}


	private JPanel getJPanel6() {
		if (jPanel6 == null) {
			jPanel6 = new JPanel();
			jPanel6.setLayout(null);
			jPanel6.setBounds(new Rectangle(31, 14, 288, 235));
			jPanel6.setBorder(BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.orange), "Gestion Productos", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
			jPanel6.add(getRegProducto(), null);
			jPanel6.add(getEliProducto(), null);
			jPanel6.add(getLisProductos(), null);
			
			
			
			getProdu().add(EliProducto);
			getProdu().add(LisProductos);
			getProdu().add(RegProducto);
		}
		return jPanel6;
	}
	private JCheckBox getLisProductos() {
		if (LisProductos == null) {
			LisProductos = new JCheckBox();
			LisProductos.setBounds(new Rectangle(29, 147, 155, 21));
			LisProductos.setText("    Buscar Producto");
		}
		return LisProductos;
	}

	
	
	private JCheckBox getEliProducto() {
		if (EliProducto == null) {
			EliProducto = new JCheckBox();
			EliProducto.setBounds(new Rectangle(31, 102, 143, 21));
			EliProducto.setText("    Retirar Producto");
		}
		return EliProducto;
	}

	
	private JCheckBox getRegProducto() {
		if (RegProducto == null) {
			RegProducto = new JCheckBox();
			RegProducto.setBounds(new Rectangle(32, 54, 177, 21));
			RegProducto.setText("    Ingresar Producto");
		}
		return RegProducto;
	}

	private JPanel getJPanel4() {
		if (jPanel4 == null) {
			jPanel4 = new JPanel();
			jPanel4.setLayout(null);
			jPanel4.add(getJPanel2(), null);
			jPanel4.add(getAceptar1(), null);
		jPanel4.add(getCancelar21(), null);
		}
		return jPanel4;
	}
	
	private JButton getCancelar21() {
		if (cancelar21 == null) {
			cancelar21 = new JButton();
			cancelar21.setBounds(new Rectangle(352, 80, 85, 26));
			cancelar21.setText("Salir");
			
cancelar21.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					
					dispose();
				}
			});
			
		
				
			
			
			
		}
		return cancelar21;
	}


	
	private JButton getAceptar1() {
		if (aceptar1 == null) {
			aceptar1 = new JButton();
			aceptar1.setText("Aceptar");
			aceptar1.setBounds(new Rectangle(352, 39, 84, 26));
			
aceptar1.addActionListener(new ActionListener(){
				
				public void actionPerformed( ActionEvent arg0 ){
					
					
					if(registrarCliente.isSelected()){
						
						IngresarCliente ven =new IngresarCliente();
						ven.setLocationRelativeTo(null);
						ven.setVisible(true);
						
						
					}
					
                   if(eliminarCliente.isSelected()){
						
						RetirarCliente re =new RetirarCliente();
						re.setLocationRelativeTo(null);
						re.setVisible(true);
						
						
					}
					
                   
					
					
                   if(listarCliente.isSelected()){
						
						BuscarCliente act =new BuscarCliente();
                        act.setLocationRelativeTo(null);
                        act.setVisible(true);
						
						
					}
					
					
					
					
					
					
					
				}
				
				
				
			});
			
			
		
			
		}
		return aceptar1;
	}



	
	
	
	
	private JPanel getJPanel2() {
		if (jPanel2 == null) {
			jPanel2 = new JPanel();
			jPanel2.setLayout(null);
			jPanel2.setBounds(new Rectangle(35, 19, 288, 267));
			jPanel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.orange), "Gestion de Clientes", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
			jPanel2.add(getRegistrarCliente(), null);
			jPanel2.add(getEliminarCliente(), null);
			jPanel2.add(getListarCliente(), null);
			
			getEmple().add(registrarCliente);
			getEmple().add(listarCliente);
			getEmple().add(eliminarCliente);
			
			
			
		}
		return jPanel2;
	}
	
	
	private JCheckBox getListarCliente() {
		if (listarCliente == null) {
			listarCliente = new JCheckBox();
			listarCliente.setBounds(new Rectangle(46, 129, 170, 21));
			listarCliente.setText("       Buscar Cliente");
		}
		return listarCliente;
	}

	private JCheckBox getRegistrarCliente() {
		if (registrarCliente == null) {
			registrarCliente = new JCheckBox();
			registrarCliente.setBounds(new Rectangle(45, 49, 167, 21));
			registrarCliente.setText("      Registrar Cliente");
		}
		return registrarCliente;
	}
	
	private JCheckBox getEliminarCliente() {
		if (eliminarCliente == null) {
			eliminarCliente = new JCheckBox();
			eliminarCliente.setBounds(new Rectangle(45, 89, 145, 21));
			eliminarCliente.setText("      Retirar Cliente");
		}
		return eliminarCliente;
	}
	/**
	 * This method initializes guardar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getGuardar() {
		if (guardar == null) {
			guardar = new JButton();
			guardar.setBounds(new Rectangle(77, 183, 97, 23));
			guardar.setText("Guardar");
			guardar.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
				
				
					String opcion= (String) jComboBox.getSelectedItem();
					//System.out.println(opcion);	
				gestion_de_productos producto= new gestion_de_productos();
				try {
					producto.cantidadInsumo(opcion,Integer.parseInt(getCantidad().getText()));
				
				
				}
				catch (Exception e1) {
					
					
					JOptionPane.showMessageDialog(null, "El siguiente campo de datos  "+ e1.getMessage()+"  no corresponde al tipo del campo");
				    e1.printStackTrace();
				}
				
				
				}
			});
		}
		return guardar;
	}
	/**
	 * This method initializes jButton3	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton3() {
		if (jButton3 == null) {
			jButton3 = new JButton();
			jButton3.setBounds(new Rectangle(222, 180, 94, 26));
			jButton3.setText("Salir");
			
			
jButton3.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					
					dispose();
				}
			});
			
			
			
		}
		return jButton3;
	}
	/**
	 * This method initializes cantidad	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getCantidad() {
		if (cantidad == null) {
			cantidad = new JTextField();
			cantidad.setBounds(new Rectangle(223, 109, 96, 22));
		}
		return cantidad;
	}

	


	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	

}  //  @jve:decl-index=0:visual-constraint="34,22"


